#include "contactlistitem.h"
#include "talkui.h"

#include <QPainter>
ContactListItem::ContactListItem(QWidget *parent) : QWidget(parent)
{
    initUi();
}

void ContactListItem::initUi()
{

    avatar=new QWidget(this);
    nickName=new QLabel(this);
    hostName=new QLabel(this);
    avatar->setFixedSize(40,40);
    avatar->move(7,7);
    nickName->move(54,10);
    hostName->move(54,27);
    avatar->installEventFilter(this);
    nickName->setStyleSheet("QLabel{ background: transparent;color:black;font:15pt;}");
    hostName->setStyleSheet("QLabel{ background: transparent;color:#bdbdbd;font:12pt;}");
}
bool ContactListItem::eventFilter(QObject *obj, QEvent *event)
{
    if(obj == avatar)
    {
        if(event->type() == QEvent::Paint)
        {
            QPainter painter(avatar);
            painter.drawPixmap(avatar->rect(), QPixmap(":/img/avatar1.png"));
        }
    }
    return QWidget::eventFilter(obj, event);
}
